<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./../../Template/generalTemplate.xhtml">


            <ui:define name="content">
                <f:view beforePhase="#{receiptSheetManagedBean.initView}"> 
                    <h:form>
                        <div style="overflow:auto;width:860px;height:495px;">  
                            <h:outputLink id="lnk" value="Print">  
                                <p:printer target="receiptSheet" />  
                                <p:graphicImage value="/images/document-print.png" style="height:25px; width:25px;" />  
                            </h:outputLink>     
                            <p:panel id="receiptSheet" header="Receipt Sheet" >
                                <div>
                                    <h:outputText style="color: lightblue;font-size:18px;" value="MerLionFood Receipt Sheet"/>
                                </div>    
                                <h:panelGrid style="border:cadetblue solid 1px;margin-top:10px; height:100px;position:relative; margin-left:10px; width:300px" columns="2" cellpadding="2">
                                    <h:outputText value="Customer Name:"/>
                                    <h:outputText value="#{receiptSheetManagedBean.company.name}"/>
                                    <h:outputText value="Street Name:"/>
                                    <h:outputText value="#{receiptSheetManagedBean.company.address.streetName}"/>
                                    <h:outputText value="City:"/>
                                    <h:outputText value="#{receiptSheetManagedBean.company.address.city}"/>
                                    <h:outputText value="Post Code:"/>
                                    <h:outputText value="#{receiptSheetManagedBean.company.address.postCode}"/>
                                </h:panelGrid>

                                  
                                <p:dataTable style ="margin-top:10px;" dynamic="true" value="#{receiptSheetManagedBean.lineItemList}" var="l">
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Proudct" />
                                        </f:facet>
                                        <h:outputText value="#{l.product.productName}" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Quantity" />
                                        </f:facet>
                                        <h:outputText value="#{l.quantity}" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Original Unit Price" />
                                        </f:facet>
                                        <h:outputText value="#{l.product.basePrice}" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Promotional Price" />
                                        </f:facet>
                                        <h:outputText value="#{l.product.promotionPrice}" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Discount" />
                                        </f:facet>
                                        <h:outputText value="#{l.discount}" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Unit Price" />
                                        </f:facet>
                                        <h:outputText value="#{l.price}" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Subtotal" />
                                        </f:facet>
                                        <h:outputText value="#{l.cumAmount}" />
                                    </p:column>  
                                </p:dataTable> 
                                <h:panelGrid style="margin-top:30px;" columns="2" cellpadding="5">
                                    <h:outputText value ="Total:"/>
                                    <h:outputText value= "#{receiptSheetManagedBean.invoice.amountPayable}"/>    
                                    <h:outputText value ="Amount Paid:"/>
                                    <h:outputText value= "#{receiptSheetManagedBean.invoice.amountPaid}"/> 
                                    <h:outputText value ="Issued Date："/>
                                    <h:outputText value= "#{receiptSheetManagedBean.receipt.issuingDate}">
                                    <f:convertDateTime pattern ="yyyy-MM-dd"/>
                                    </h:outputText>
              
                                </h:panelGrid>
                                <h:outputText value="Thanks For Doing Business With Us" style="margin-top:350px;color: darkcyan; font-size:18px;margin-left:280px;"/>

                            </p:panel> 
          
                            <p:commandButton style="margin-top:20px;" value="View Record" action="${receiptSheetManagedBean.viewRecord()}"/>
                        </div>

                    </h:form>
                </f:view>   
            </ui:define>

        </ui:composition>

    </body>
</html>
